'''
通过Python创建文件并写入
'''

# 方法1
import csv

headers = ['品牌名称', '品牌说明']
rows = [('金士顿', '测试数据'), ('英业达', '测试数据'), ('联想拯救者', '测试数据'), ('财神桥', '测试数据')]
with open('pinpai2.csv', 'w', encoding='utf8', newline='') as f:
    writer = csv.writer(f)
    writer.writerow(headers)
    writer.writerows(rows)

# 方法2
'''
#coding=gbk
import csv, os

sFilename = os.path.join('F:\\test\\典型案例', '.csv')
eFile = open('write.csv', 'w+', encoding='gbk',newline='')
eWriter = csv.writer(eFile, delimiter=',', lineterminator='\r\n')
eWriter.writerow(['F1122331', '丢弃', '保存成功！'])
eFile.close()
'''
